#!/bin/bash

# 读取文件内容
file_content=$(cat /etc/X11/xorg.conf.d/99-gpu.conf)

# 使用 grep 查找匹配字符串
if echo "$file_content" | grep -q 'Screen 0 "nvidia"'; then
	sed -i 's/Screen 0 "nvidia"/Screen 0 "intel"/' /etc/X11/xorg.conf.d/99-gpu.conf
	sed -i 's/Inactive "intel"/Inactive "nvidia"/' /etc/X11/xorg.conf.d/99-gpu.conf
	echo "switch to intel prefer\n"
else
	sed -i 's/Screen 0 "intel"/Screen 0 "nvidia"/' /etc/X11/xorg.conf.d/99-gpu.conf
	sed -i 's/Inactive "nvidia"/Inactive "intel"/' /etc/X11/xorg.conf.d/99-gpu.conf
	echo "switch to nvidia prefer\n"
fi

#cat /etc/X11/xorg.conf.d/99-gpu.conf
